﻿var uploadedDataURL = "/asset/get/s/data-1544592880173-tRoZbKmvl.json";
var map = new AMap.Map('chart-panel', {
    layers: [
        // 卫星
        new AMap.TileLayer.Satellite(),
        // 路网
        new AMap.TileLayer.RoadNet()
    ]
});
AMapUI.load(['ui/geo/DistrictCluster', 'ui/misc/PointSimplifier', 'lib/$'], function(DistrictCluster, PointSimplifier, $) {

    var pointSimplifierIns = new PointSimplifier({
        map: map, //所属的地图实例
        autoSetFitView: false, //禁止自动更新地图视野
        zIndex: 110,
        getPosition: function(item) {
            return [item.longitude, item.latitude];
        },
        getHoverTitle: function(dataItem, idx) {
            return dataItem.company_name + ': ' + dataItem.industry;
        },
        renderOptions: {
            //点的样式
            pointStyle: {
                width: 6,
                height: 6,
                fillStyle: 'rgba(153, 0, 153, 0.38)'
            },
            //鼠标hover时的title信息
            hoverTitleStyle: {
                position: 'top'
            }
        }
    });

    $('<div id="loadingTip">加载数据，请稍候...</div>').appendTo(document.body);
    $.getJSON(uploadedDataURL, function(data) {

        $('#loadingTip').remove();
        var distCluster = new DistrictCluster({
            zIndex: 100,
            map: map, //所属的地图实例
            topAdcodes: [110000, 120000, 130000],
            getPosition: function(item) {
                return [item.longitude, item.latitude];
            },
            boundsQuerySupport:true,
        });

        distCluster.setData(data);

        pointSimplifierIns.setData(data);
    });
});
